<?php
if (@$_GET['lang'] == "")
{
	$_GET['lang']="pl";
}
$zawartoscPliku = file_get_contents("lang/".$_GET['lang'].".json");
$tab = (array)json_decode($zawartoscPliku);
require_once("KsiegaGosci.php");

$ksiega = KsiegaGosci::get("sql",false);

if (isset($_POST['wpis'])) {
	$ksiega->zapisz($_POST['wpis']);
}
$tab['wynik'] = $ksiega->odczytaj();
?>
<html>
<head>
<meta charset="utf-8">
<title><?php echo($tab['ksiega_gosci']); ?></title>
</head>
<body>
 <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
    function Delete()
    {
        $.ajax({
            url    : 'delete.php',
			dataType: 'json',
            success: function(data) {
                $("#result").html("<?php echo($tab['skasowano']); ?>");
				$("#left").html('');
            }
        });
    }
    </script>
</head>
<center><h1><?php echo($tab['ksiega_gosci']); ?></h1>
<div id=result></div>
<div id="left">
<?php
echo $tab['wynik'];
?>
</div>
<div id=right>
<form action=index.php method=post>
<input type=text name=wpis />
<input type=submit value="<?php echo($tab['dodaj']); ?>" />
</form>
<br />
<button onClick="Delete()"><?php echo($tab['usun_wszystkie_wpisy']); ?></button>
</div>
</center>
</body>
</html>
